﻿function approval(){
	
	var chekedLength = $('input[name="myHoverTreechk"]:checked').length;
	
	if(chekedLength <= 0){
		toastr.warning('请选择一个加盟商进行审核！');
		return;
	}
	if(chekedLength > 1){
		toastr.warning('只能选择一个加盟商进行审核！');
		return;	
	}
	
	var status = $('input[name="myHoverTreechk"]:checked').data('status');
	if(status != 0){
		toastr.warning('此加盟商已审核！');
		return;	
	}
	
	var id = $('input[name="myHoverTreechk"]:checked').val();
	
	location.href = ctx + "/franchisee/toFranchiseeAdd?from=approval&id=" +　id;
	
}


window.onload = function() {
    document.getElementById("params").focus();
}


function deleteRecord(id){
	
	$.ajax({
		url : ctx + '/franchisee/deleteFranchisee',
		data : {id : id},
		dataType : 'json',
		type : 'post',
		success : function(data){
			if(data.status == "success")
				location.href = ctx +　"/franchisee/franchisee";
			else
				alert('删除错误！');
		},
		error : function(){
			alert("系统错误");
		}
	});
	
}



function deleteBatch(){
	
	var checks =[]; 
	
	$('input[name="myHoverTreechk"]:checked').each(function(){ 
		checks.push($(this).val()); 
	}); 
	
	if(checks.length == 0)
		return;
	
	$.ajax({
		url : ctx + '/franchisee/deleteFranchiseeBatch',
		data : {checks:checks},
		dataType : 'json',
		type : 'post',
		success : function(data){
			if(data.status != "success"){
				alert(data.msg);
			}else{
				location.href = ctx + '/franchisee/franchisee';
			}
		},
		error : function(){
			alert("系统错误");
		}
	});
	
}








